package me.sdevil507.systemAssist.systemLog.po;

import lombok.Data;
import lombok.EqualsAndHashCode;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdEntity;
import org.hibernate.annotations.Formula;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.util.Date;

/**
 * 操作日志
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "system_log_oper")
public class SystemOperLogPo extends BaseJpaSnowflakeIdEntity {

    /**
     * 操作终端
     */
    @Column
    private String operTerminal;
    /**
     * 操作来源机构
     */
    @Column
    private Long operOrgId;
    @Formula("(SELECT t.name_zh from biz_org as t where t.id=oper_org_id)")
    private String operOrgName;
    /**
     * 操作分类
     */
    @Column
    private String operClassify;
    /**
     * 操作模块
     */
    @Column
    private String operModule;
    /**
     * 操作描述
     */
    @Column
    private String operDesc;
    /**
     * 操作方法
     */
    @Column
    private String operMethod;
    /**
     * 请求URI
     */
    @Column
    private String operRequestURI;
    /**
     * 请求IP
     */
    @Column
    private String operRequestIp;
    /**
     * 请求参数
     */
    @Column(columnDefinition = "text")
    @Lob
    private String operRequestParam;
    /**
     * 返回参数
     */
    @Column(columnDefinition = "text")
    @Lob
    private String operReturnParam;
    /**
     * 操作人id
     */
    @Column
    private Long userId;
    /**
     * 操作人id
     */
    @Column
    private String userName;
    @Formula("(select t.realname from user as t  where t.id=user_id)")
    private String orgRealUserName;
    @Formula("(select t.realname from user as t  where t.id=user_id)")
    private String platformUserRealName;
    /**
     * 创建时间
     */
    @Column
    private Date createTime = new Date();
}
